/*
 =============================================================================
 FILE...............: Booking.java
 COMMENTS...........: Model of a flight booking.
 =============================================================================
 AUTHOR(S)..........: Everton Ranielly de Sousa Cavalcante
 					  Department of Informatics and Applied Mathematics
 					  Federal University of Rio Grande do Norte
 LAST MODIFICATION..: October 13rd, 2012
 ============================================================================= 					  
*/


/* ========================================================================= */
/* PACKAGES			                                                         */
/* ------------------------------------------------------------------------- */
package model;

import javax.xml.bind.annotation.XmlRootElement;


/* ========================================================================= */
/* CLASS Booking				                                             */
/* ------------------------------------------------------------------------- */
/**
 * Model of a flight booking
 * @author Everton Cavalcante
 */
@XmlRootElement
public class Booking
{
	private String bookingCode;		// 8-letter flight booking code
	private Flight flight01;		// Departure flight
	private Flight flight02;		// Return flight
	private Client client;			// Client who has made the flight booking
	private double value;			// Value
	private String observations;	// Additional information
	private String flightClass;		// Flight class (first, business or economy)
	
	
	/** Default constructor */
	public Booking()
	{ /* Empty */ }
	
	
	/** Constructor */
	public Booking(Flight departureFlight, Flight returnFlight, Client client)
	{
		this.flight01 = departureFlight;
		this.flight02 = returnFlight;
		
		this.setClient(client);
		this.setValue(0.00);
		this.setObservations("");
		this.setFlightClass("");
	}
	
	
	/**
	 * Returns the 8-letter flight booking code
	 * @return bookingCode Flight booking code
	 */
	public String getBookingCode() 
	{ return bookingCode; }
	
	
	/**
	 * Modifies the flight booking code
	 * @param bookingCode 8-letter code to set
	 */
	public void setBookingCode(String bookingCode)
	{ this.bookingCode = bookingCode; }
	
	
	/**
	 * Returns the departure flight
	 * @return Departure flight
	 */
	public Flight getFlight01()
	{ return flight01; }
	
	
	/**
	 * Returns the return flight
	 * @return Return flight
	 */
	public Flight getFlight02()
	{ return flight02; }
	
	
	/**
	 * Modifies the departure flight
	 * @param flight Flight to set
	 */
	public void setFlight01(Flight flight)
	{ flight01=flight; }
	
	
	/**
	 * Modifies the return flight
	 * @param flight Flight to set
	 */
	public void setFlight02(Flight flight)
	{ flight02=flight; }
	
	
	/**
	 * Returns the reference to the client who has booked the flight
	 * @return client Client who has booked the flight
	 */
	public Client getClient() 
	{ return client; }
	
	
	/**
	 * Modifies the reference to the client
	 * @param client Client reference to set
	 */
	public void setClient(Client client) 
	{ this.client = client; }
	
	
	/**
	 * Returns the value paid for the booking
	 * @return value Value paid for the booking
	 */
	public double getValue() 
	{ return value; }
	
	
	/**
	 * Modifies the value to be paid
	 * @param value Value to set
	 */
	public void setValue(double value) 
	{ this.value = value; }
	
	
	/**
	 * Returns the additional information regarding the booking
	 * @return observations Additional information
	 */
	public String getObservations() 
	{ return observations; }
	
	
	/**
	 * Modifies the additional information regarding the booking
	 * @param observations Additional information to set
	 */
	public void setObservations(String observations) 
	{ this.observations = observations; }
	
	
	/**
	 * Returns the booked flight class
	 * @return flightClass Booked flight class (first, business or economy)
	 */
	public String getFlightClass() 
	{ return flightClass; }
	
	
	/**
	 * Modifies the booked flight class
	 * @param flightClass Flight class to set
	 */
	public void setFlightClass(String flightClass) 
	{ this.flightClass = flightClass; }
	
	
	@Override
	public String toString()
	{
		String booking = "";
		booking += "BOOKING CODE:\n" + this.getBookingCode() + "\n\n";
		booking += "PASSENGER INFORMATION:\n";
		booking += this.getClient().getTitle() + " " + client.getName() + "\n";
		booking += "Email: " + this.getClient().getEmail() + "\n";
		booking += "Phone: " + this.getClient().getPhone() + "\n\n";
		booking += "TRIP SUMMARY\n";
		booking += "Departure flight:\n";
		booking += this.getFlight01().toString() + "\n\n";
		booking += "Return flight:\n";
		booking += this.getFlight02().toString() + "\n\n";
		booking += "PAYMENT INFORMATION:\n";
		booking += "Value to be paid: " + this.getValue() + "\n";
		booking += "Credit card number: " + this.getClient().getCreditCardNumber() + "\n\n";
		booking += "ADDITIONAL INFORMATION:\n" + this.getObservations() + "\n";
		
		return booking;
	}
}
